package com.travel.travelnetwork.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.travel.travelnetwork.mapper.PermissionMapper;
import com.travel.travelnetwork.mapper.RoleMapper;
import com.travel.travelnetwork.pojo.Permission;
import com.travel.travelnetwork.pojo.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;

    //查询所有权限
    public Page<Permission> findPage(int page, int size) {
        return permissionMapper.selectPage(new Page<>(page,size),null);
    }
    //新增角色
    public void  addPermission(Permission permission) {
        permissionMapper.insert(permission);
    }

    //查询角色
    public Permission findPermissionById(Integer pid) {
        return permissionMapper.selectById(pid);
    }

    //修改角色
    public void updatePermission(Permission permission) {
        permissionMapper.updateById(permission);
    }

    //删除角色
    public void deletePermission(Integer pid) {
        permissionMapper.deleteById(pid);
    }
}
